/// describe
///
/// created by hujintao
/// created at 2021/5/10
//

import 'package:flutter/material.dart';
import 'package:flutterappdriver/provider/color_provider.dart';
import 'package:flutterappdriver/utils/screen.dart';
import 'package:flutterappdriver/utils/utils.dart';
import 'package:provider/provider.dart';

class MinePage extends StatefulWidget {
  @override
  _MinePageState createState() => _MinePageState();
}

class _MinePageState extends State<MinePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.white,
      body: Column(
        children: [
          TabUserHeader(),
          SizedBox(height: 50),
          TabUserCell(),
        ],
      ),
    );
  }
}

class TabUserCell extends StatelessWidget {
  const TabUserCell({
    Key? key,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return InkWell(
      onTap: () {},
      child: Container(
        margin: EdgeInsets.symmetric(horizontal: 15),
        padding: EdgeInsets.symmetric(vertical: 15, horizontal: 15),
        decoration: BoxDecoration(
            border: Border(
          bottom: Divider.createBorderSide(context, width: 0.7),
          top: Divider.createBorderSide(context, width: 0.7),
        )),
        child: Row(
          children: [
            Text("我的收藏"),
            Expanded(child: SizedBox.shrink()),
            Icon(Icons.arrow_forward_ios)
          ],
        ),
      ),
    );
  }
}

class TabUserHeader extends StatelessWidget {
  const TabUserHeader({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Stack(
      clipBehavior: Clip.none,
      children: [
        ClipPath(
          clipper: BottomClipper(),
          child: Container(
            color: Theme.of(context).primaryColor,
            height: 240,
            padding: EdgeInsets.only(top: 10),
          ),
        ),
        Positioned(
            left: 0,
            top: 10,
            width: Screen.width,
            height: 220,
            child: SafeArea(child: Container(
              padding: EdgeInsets.all(20),
              alignment: Alignment.center,
              child: Column(
                mainAxisAlignment: MainAxisAlignment.center,
                children: <Widget>[
                  ClipOval(
                      child: Image.asset(
                        "./assets/images/Steven.png",
                        width: 80.0,
                      )),
                  Padding(
                    padding: const EdgeInsets.all(8.0),
                    child: Text(
                      "StevenHu",
                      textScaleFactor: 1.2,
                    ),
                  ),
                  Text(
                    "183****1969",
                    style: TextStyle(
                      fontSize: 12,
                      color: Colors.white,
                    ),
                  ),
                ],
              ),
            ),))
      ],
    );
  }
}

class BottomClipper extends CustomClipper<Path> {
  @override
  getClip(Size size) {
    var path = Path();
    path.lineTo(0, 0);
    path.lineTo(0, size.height - 50);

    var p1 = Offset(size.width / 2, size.height);
    var p2 = Offset(size.width, size.height - 50);
    path.quadraticBezierTo(p1.dx, p1.dy, p2.dx, p2.dy);
    path.lineTo(size.width, size.height - 50);
    path.lineTo(size.width, 0);
    return path;
  }

  @override
  bool shouldReclip(CustomClipper oldClipper) {
    return false;
  }
}
